package edu.sctu.jarime.may.subway.util;

import edu.sctu.jarime.may.subway.appbean.PeopleAppbean;
import edu.sctu.jarime.may.subway.data.SetPeopleData;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by user19 on 2015/6/7.
 */
public class TimeDeth  extends Thread{
    private PeopleAppbean peopleappbean;

    public TimeDeth(PeopleAppbean peopleappbean){
        peopleappbean = new SetPeopleData().setpeopledata().get(0);
        this.peopleappbean = peopleappbean;

    }

    public void run() {
            Date date = new Date();//date对象代表当前的系统时间(毫秒)
            SimpleDateFormat from = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//format对象是用来以指定的时间格式格式化时间的
            String times= from.format(date);//format()方法是用来格式化时间的方法
            System.out.println("您的进站时间是"+times);//进站时间
            System.out.println("行程中...");
            int count=new SubwayCardDeth().conutStationNumber(peopleappbean.getStart(),peopleappbean.getEnd());


            try {
                sleep(count*2000);
                System.out.println("您乘坐时间为"+count*2000/1000+"s");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            Date dateout = new Date();
            String timesout = from.format(dateout);//format()方法是用来格式化时间的方法
            System.out.println("您的出站时间是"+timesout);


    }
}
